﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Dimok;

public partial class Manager_Lib_Controls_ShowDocuments : System.Web.UI.UserControl {
	public string DocsPath { get; set; }
	protected void Page_Load(object sender, EventArgs e) {
		DocsPath = this.NamingContainer.GetProperty("DocsPath") + "";
		lnqDocs.Selecting += new EventHandler<LinqDataSourceSelectEventArgs>(lnqDocs_Selecting);
	}

	protected void lnqDocs_Selecting(object sender, LinqDataSourceSelectEventArgs e) {
		var path = Server.MapPath(DocsPath);
		var docs = System.IO.Directory.GetFiles(path).Select(f => f.Replace(Server.MapPath("/"), "\\").ToLower());
		var mb = new Data.LINQ.MotoBank();
		e.Result = from vn in mb.ts_Document_Views.ToArray()
							 join d in docs on vn.Path.ToLower() equals d
							 select vn;
	}
}
